feat: Use Backend for Recipe Post Actions #4163
Merged
+159
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
This leverages the backend to make
POST
requests for recipe actions. The previous implementation had issues requiring us to send the content typetext/plain
. Using the backend we get around this. Consequently, it's also a lot faster for the user since we don't have to wait for the response from the external server (the backend uses background tasks from FastAPI so it can return a202
response immediately).Since we now send the correct content header (
application/json
) it should work nicely with Home Assistant. Since this feature was already slightly broken because of the content header, I took this time to improve the actual payload to include the recipe action. This results in a breaking change, though a minor one (since it was impossible to extract the body previously anyway in a lot of applications). We also don't use merge fields in the POST type, since we're already sending all the data in the payload anyway.Which issue(s) this PR fixes:
(REQUIRED)
Fixes #3936
Testing
(fill-in or delete this section)
Pytest backend, manual frontend